import std.stdio;
import bignum;

//足し算で2**r
Bignum pow2(int r) {
  Bignum n = new Bignum(1);
  for(int i=0; i<r; i++) {
    n=bigadd(n,n);
  }
  return n;
}

//足し算で3**r
Bignum pow3(int r) {
  Bignum m = new Bignum(1);
  for(int i=0; i<r; i++) {
    m=bigadd(bigadd(m,m),m);
  }
  return m;
}

//掛け算で2**r
Bignum pow2m(int r) {
  int[] a;
  while(r>0) {
    a~=r%2;
    r/=2;
  }

  Bignum ni=new Bignum(2);
  Bignum n=new Bignum(1);

  foreach(int i; a.reverse) { //.reverseは破壊的に注意
    if(i) {
      n=bigmul(bigmul(n,n),ni);
//      n=bigmul(n,n); n=bigadd(n,n);
    } else {
      n=bigmul(n,n);
    }
  }
  return n;
}

void main() {
//  writefln(pow2(100000));
//  writefln(pow2m(100000));
  writefln(bigsub(pow2(100000),pow2m(100000)));
  writefln(bigsub(pow2(1000),pow3(631)));
  writefln(bigdiv(pow2m(1000),pow3(500)));
}
